package cn.dakaqi.web.api.v1;

import cn.dakaqi.entities.PinganOpen;
import cn.dakaqi.pingan.services.PinganInsuranceService;
import cn.dakaqi.utils.JsonResult;
import com.wordnik.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springside.modules.web.MediaTypes;

import javax.annotation.Resource;

/**
 * Created by chunyang on 2016/4/7.
 * 用户
 */
@RestController
@RequestMapping(value = "/api/v1/pingan")
@Slf4j
@Api(value = "平安保险购买")
public class PinganController {

    @Resource
    private PinganInsuranceService pinganInsuranceService;

    @RequestMapping(value = "/create", method = RequestMethod.POST, produces = MediaTypes.JSON_UTF_8)
    public ResponseEntity<JsonResult> create(@RequestBody PinganOpen param) {
        JsonResult jsonResult = pinganInsuranceService.createInsurance(param);
        return new ResponseEntity<JsonResult>(jsonResult, HttpStatus.OK);
    }

    @RequestMapping(value = "/activityPingan", method = RequestMethod.POST, produces = MediaTypes.JSON_UTF_8)
    public ResponseEntity<JsonResult> activityPingan(@RequestBody PinganOpen param) {
        JsonResult jsonResult = pinganInsuranceService.activityPingan(param.getVolunteerCode());
        return new ResponseEntity<JsonResult>(jsonResult, HttpStatus.OK);
    }
}
